package com.hiultra.archive.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hiultra.common.annotation.Log;
import com.hiultra.common.core.controller.BaseController;
import com.hiultra.common.core.domain.AjaxResult;
import com.hiultra.common.enums.BusinessType;
import com.hiultra.archive.domain.ArcDestroyDetail;
import com.hiultra.archive.service.IArcDestroyDetailService;
import com.hiultra.common.utils.poi.ExcelUtil;
import com.hiultra.common.core.page.TableDataInfo;

/**
 * 销毁详情Controller
 * 
 * @author ls
 * @date 2023-09-02
 */
@RestController
@RequestMapping("/archive/destroyDetail")
public class ArcDestroyDetailController extends BaseController
{
    @Autowired
    private IArcDestroyDetailService arcDestroyDetailService;

    /**
     * 查询销毁详情列表
     */
    @PreAuthorize("@ss.hasPermi('archive:destroyDetail:list')")
    @GetMapping("/list")
    public TableDataInfo list(ArcDestroyDetail arcDestroyDetail)
    {
        startPage();
        List<ArcDestroyDetail> list = arcDestroyDetailService.selectArcDestroyDetailList(arcDestroyDetail);
        return getDataTable(list);
    }

    /**
     * 导出销毁详情列表
     */
    @PreAuthorize("@ss.hasPermi('archive:destroyDetail:export')")
    @Log(title = "销毁详情", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ArcDestroyDetail arcDestroyDetail)
    {
        List<ArcDestroyDetail> list = arcDestroyDetailService.selectArcDestroyDetailList(arcDestroyDetail);
        ExcelUtil<ArcDestroyDetail> util = new ExcelUtil<ArcDestroyDetail>(ArcDestroyDetail.class);
        util.exportExcel(response, list, "销毁详情数据");
    }

    /**
     * 获取销毁详情详细信息
     */
    @PreAuthorize("@ss.hasPermi('archive:destroyDetail:query')")
    @GetMapping(value = "/{destroyDetailId}")
    public AjaxResult getInfo(@PathVariable("destroyDetailId") Long destroyDetailId)
    {
        return AjaxResult.success(arcDestroyDetailService.selectArcDestroyDetailByDestroyDetailId(destroyDetailId));
    }

    /**
     * 新增销毁详情
     */
    @PreAuthorize("@ss.hasPermi('archive:destroyDetail:add')")
    @Log(title = "销毁详情", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ArcDestroyDetail arcDestroyDetail)
    {
        return toAjax(arcDestroyDetailService.insertArcDestroyDetail(arcDestroyDetail));
    }

    /**
     * 修改销毁详情
     */
    @PreAuthorize("@ss.hasPermi('archive:destroyDetail:edit')")
    @Log(title = "销毁详情", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ArcDestroyDetail arcDestroyDetail)
    {
        return toAjax(arcDestroyDetailService.updateArcDestroyDetail(arcDestroyDetail));
    }

    /**
     * 删除销毁详情
     */
    @PreAuthorize("@ss.hasPermi('archive:destroyDetail:remove')")
    @Log(title = "销毁详情", businessType = BusinessType.DELETE)
	@DeleteMapping("/{destroyDetailIds}")
    public AjaxResult remove(@PathVariable Long[] destroyDetailIds)
    {
        return toAjax(arcDestroyDetailService.deleteArcDestroyDetailByDestroyDetailIds(destroyDetailIds));
    }
}
